<template>
    <div>
        <div class="e-form">
            <div class="tabs" style="margin-bottom:120px">
                <div class="tabs-title">基本信息</div>
                <div style="width: 100%" class="form">
                    <el-form :model="formData" :label-width="formLabelWidth">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="合同编号：">
                                    <span>{{formData.ctCode}}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="合同名称：">
                                    <el-input v-model="formData.ctName" autocomplete="off"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="管理单位：">
                                    <span>{{}}</span>
                                    <!-- <el-input v-model="formData.ctName" autocomplete="off"></el-input> -->
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="工程概况：">
                                    <span>{{}}</span>
                                    <!-- <el-input v-model="formData.ctName" autocomplete="off"></el-input> -->
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="合同工期(月)：">
                                    <span>{{}}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="经办人：">
                                    <span>{{formData.handler}}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="签订日期：">
                                    <el-date-picker type="date" value-format="yyyy-MM-dd" placeholder="选择日期" v-model="formData.signingDate"></el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="税率%：">
                                    <el-input v-model="formData.taxRate"  v-enter-number autocomplete="off"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="税额(元)：">
                                    <el-input v-model="formData.taxAmount" v-enter-number autocomplete="off"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="不含税金额(元)：">
                                    <span>{{formData.notTaxprice}}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="合同净价(元)：">
                                    <span>{{}}</span>
                                    <!-- <el-input v-model="formData.taxAmount" v-enter-number autocomplete="off"></el-input> -->
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="合同金额(元)：">
                                    <span>{{formData.ctMoney}}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="暂列金额(元)：">
                                    <span>{{}}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="变更次数：">
                                    <span>{{}}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="币种：">
                                    <el-select v-model="formData.currency" placeholder="请选择">
                                        <el-option
                                            v-for="(
                                                item, index
                                            ) in options.currencyForm"
                                            :key="index"
                                            :label="item"
                                            :value="index"
                                        >
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="状态：">
                                    <span>{{options.ctStateForm[formData.ctState]}}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="签约人：">
                                    <el-input v-model="formData.signatory" autocomplete="off">
                                        <i
                                            class="
                                                el-icon-document-copy
                                            "
                                            slot="suffix"
                                        >
                                        </i>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="全额保留几位小数">
                                    <span>{{}}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="修改人：">
                                    <span>{{}}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="人民币汇率">
                                    <span>{{}}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="签订地点：">
                                    <SelectAddr v-model="ctAddressCode" @getLabel="getAddrLabel"
                                            lazy
                                            showCountry
                                            style="width: 100%;"
                                    ></SelectAddr>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="备注：">
                                    <el-input type="textarea" v-model="formData.ctPrimarycoverage" autocomplete="off"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </div>
            <div class="buttons">
                <el-button type="primary" size="small" style="background: #2e61d7"
                    >变更</el-button
                >
                <el-button type="primary" size="small" style="background: #2e61d7"
                    >打印</el-button
                >
                <el-button type="primary" size="small" style="background: #2e61d7"
                    >审核</el-button
                >
                <el-button type="primary" size="small" style="background: #2e61d7" @click="addSave"
                    >保存</el-button
                >
                <el-button type="primary" size="small" style="background: #2e61d7"
                    >保存并提交</el-button
                >
                <el-button  type="danger" size="small"
                    >撤回</el-button
                >
                <el-button  type="danger" size="small"
                    >删除</el-button
                >
                <el-button  type="danger" size="small"
                    >作废</el-button
                >
                <el-button size="small" @click="handleClose">关闭</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex'
import SelectAddr from '@/components/common/addrComp'
export default {
    data () {
        return {
            //基础信息
            formData: {
                'advanceCharge': null,
                'aname': '',
                'applicationStatus': '',
                'baseCurrency': null,
                'baseRate': null,
                'bcAdvanceCharge': null,
                'bcCtMoney': null,
                'bcPerformanceBond': null,
                'bname': '',
                'cashPledge': null,
                'cashPledges': null,
                'changeAdvanceCharge': null,
                'changeCode': '',
                'changeCtMoney': null,
                'changeNumber': null,
                'ctAddressCode': '',
                'ctCode': '',
                'ctMoney': null,
                'ctName': '',
                'ctPrimarycoverage': '',
                'ctState': null,
                'ctType': null,
                'ctsubcontractId': '',
                'financialSharing': null,
                'freightTaxRate': null,
                'gmtCreate': '',
                'gmtModified': '',
                'guaranteedAmount': null,
                'handler': '',
                'importId': '',
                'importName': '',
                'intoMoney': null,
                'isDelete': null,
                'isPerformanceBond': null,
                'isTax': null,
                'leasePlan': '',
                'notTaxprice': null,
                'nullifyCreated': '',
                'nullifyCreator': '',
                'nullifyCreatorId': '',
                'nullifyDesciption': '',
                'nullifyReason': '',
                'orgId': '',
                'organization': '',
                'outMoney': null,
                'signatory': '',
                'signatoryAddress': '',
                'signingDate': '',
                'supplier': '',
                'taxAmount': null,
                'taxRate': null,
                'transportationCost': null,
                'userId': '',
                'validity1': '',
                'validity2': ''
            },
            formLabelWidth: '180px',
            ctAddressCode: []
        }
    },
    mounted () {
        this.getUserInfo()
    },
    components: {
        SelectAddr
    },
    computed: {
        ...mapState({
            options: state => state.contract.ctClassify,
            userInfo: state => state.userInfo
        })
    },
    methods: {
        //默认获取用户信息
        getUserInfo () {
            this.formData.importId = localStorage.userId
            this.formData.importName = localStorage.userName
            this.formData.orgId = this.userInfo.orgInfo.orgId
            this.formData.organization = this.userInfo.orgInfo.orgName  //所属机构
            this.formData.handler = localStorage.userName
        },
        // 获取地址对应中文
        getAddrLabel (val) {
            this.formData.signatoryAddress = val.join('-')
        },
        //基本信息保存
        addSave () {
            if(this.ctAddressCode.length > 0) {
                this.formData.ctAddressCode = this.ctAddressCode.join('-') //行政编码
            }
            this.$Ajax.httpPost({
                url: '/contract/CtConveyancePsdreparationd/saveOne',
                params: this.formData
            }).then(() => {
                this.$message.success('保存成功')
                this.$router.push('/landlordSginingContract')

            })
        },
        //取消
        handleClose () {
            this.$router.push('/landlordSginingContract')
        },
    },
}

</script>

<style lang='scss' scoped>
.buttons {
    left: 0;
}
.e-form {
    padding: 0 20px;
    .tabs-title::before {
        content: '';
        height: 22px;
        width: 8px;
        border-radius: 40px;
        background-color: #2e61d7;
        display: block;
        position: absolute;
        left: 20px;
        margin-right: 20px;
    }
}
.e-table{
    min-height: auto;
    background: #fff;
}
.separ{
   width: 30px;
   height: 40px;
   line-height: 18px;
   text-align: center;
}
.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}

::v-deep.el-input--suffix .el-input__inner {
    padding-right: 5px;
}
::v-deep.el-table .cell {
    text-align: center;
}
</style>